package com.zr.earthquate.db.greendao;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.util.Log;

import org.greenrobot.greendao.AbstractDaoMaster;
import org.greenrobot.greendao.database.StandardDatabase;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseOpenHelper;
import org.greenrobot.greendao.identityscope.IdentityScopeType;


// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
 * Master of DAO (schema version 3): knows all DAOs.
 */
public class DaoMaster extends AbstractDaoMaster {
    public static final int SCHEMA_VERSION = 3;

    /** Creates underlying database table using DAOs. */
    public static void createAllTables(Database db, boolean ifNotExists) {
        CreaterDbEntityDao.createTable(db, ifNotExists);
        DrillHoleDbEntityDao.createTable(db, ifNotExists);
        FaultSvyPointDbEntityDao.createTable(db, ifNotExists);
        GeochemicalSvyLineDbEntityDao.createTable(db, ifNotExists);
        GeochemicalSvyPointDbEntityDao.createTable(db, ifNotExists);
        GeoGeomorphySvyPointDbEntityDao.createTable(db, ifNotExists);
        GeologicalSvyLineDbEntitiyDao.createTable(db, ifNotExists);
        GeologicalSvyPlanningLineDbEntityDao.createTable(db, ifNotExists);
        GeologicalSvyPlanningPtDbEntityDao.createTable(db, ifNotExists);
        GeologicalSvyPointDbEntityDao.createTable(db, ifNotExists);
        GeomorphySvyLineDbEntityDao.createTable(db, ifNotExists);
        GeomorphySvyPointDbEntityDao.createTable(db, ifNotExists);
        GeomorphySvyRegionDbEntityDao.createTable(db, ifNotExists);
        GeomorphySvyReProfDbEntityDao.createTable(db, ifNotExists);
        GeomorphySvySamplePointDbEntityDao.createTable(db, ifNotExists);
        GeomorStationDbEntityDao.createTable(db, ifNotExists);
        GeophySvyLineDbEntityDao.createTable(db, ifNotExists);
        GeophySvyPointDbEntityDao.createTable(db, ifNotExists);
        LavaDbEntityDao.createTable(db, ifNotExists);
        LocationEntityDao.createTable(db, ifNotExists);
        RelationTaskDbBeanDao.createTable(db, ifNotExists);
        SamplePointDbEntityDao.createTable(db, ifNotExists);
        StratigraphySvyPointDbEntityDao.createTable(db, ifNotExists);
        TanCaodianDbEntityDao.createTable(db, ifNotExists);
        VolcanicSamplePointDbEntityDao.createTable(db, ifNotExists);
        VolcanicSvyPointDbEntityDao.createTable(db, ifNotExists);
    }

    /** Drops underlying database table using DAOs. */
    public static void dropAllTables(Database db, boolean ifExists) {
        CreaterDbEntityDao.dropTable(db, ifExists);
        DrillHoleDbEntityDao.dropTable(db, ifExists);
        FaultSvyPointDbEntityDao.dropTable(db, ifExists);
        GeochemicalSvyLineDbEntityDao.dropTable(db, ifExists);
        GeochemicalSvyPointDbEntityDao.dropTable(db, ifExists);
        GeoGeomorphySvyPointDbEntityDao.dropTable(db, ifExists);
        GeologicalSvyLineDbEntitiyDao.dropTable(db, ifExists);
        GeologicalSvyPlanningLineDbEntityDao.dropTable(db, ifExists);
        GeologicalSvyPlanningPtDbEntityDao.dropTable(db, ifExists);
        GeologicalSvyPointDbEntityDao.dropTable(db, ifExists);
        GeomorphySvyLineDbEntityDao.dropTable(db, ifExists);
        GeomorphySvyPointDbEntityDao.dropTable(db, ifExists);
        GeomorphySvyRegionDbEntityDao.dropTable(db, ifExists);
        GeomorphySvyReProfDbEntityDao.dropTable(db, ifExists);
        GeomorphySvySamplePointDbEntityDao.dropTable(db, ifExists);
        GeomorStationDbEntityDao.dropTable(db, ifExists);
        GeophySvyLineDbEntityDao.dropTable(db, ifExists);
        GeophySvyPointDbEntityDao.dropTable(db, ifExists);
        LavaDbEntityDao.dropTable(db, ifExists);
        LocationEntityDao.dropTable(db, ifExists);
        RelationTaskDbBeanDao.dropTable(db, ifExists);
        SamplePointDbEntityDao.dropTable(db, ifExists);
        StratigraphySvyPointDbEntityDao.dropTable(db, ifExists);
        TanCaodianDbEntityDao.dropTable(db, ifExists);
        VolcanicSamplePointDbEntityDao.dropTable(db, ifExists);
        VolcanicSvyPointDbEntityDao.dropTable(db, ifExists);
    }

    /**
     * WARNING: Drops all table on Upgrade! Use only during development.
     * Convenience method using a {@link DevOpenHelper}.
     */
    public static DaoSession newDevSession(Context context, String name) {
        Database db = new DevOpenHelper(context, name).getWritableDb();
        DaoMaster daoMaster = new DaoMaster(db);
        return daoMaster.newSession();
    }

    public DaoMaster(SQLiteDatabase db) {
        this(new StandardDatabase(db));
    }

    public DaoMaster(Database db) {
        super(db, SCHEMA_VERSION);
        registerDaoClass(CreaterDbEntityDao.class);
        registerDaoClass(DrillHoleDbEntityDao.class);
        registerDaoClass(FaultSvyPointDbEntityDao.class);
        registerDaoClass(GeochemicalSvyLineDbEntityDao.class);
        registerDaoClass(GeochemicalSvyPointDbEntityDao.class);
        registerDaoClass(GeoGeomorphySvyPointDbEntityDao.class);
        registerDaoClass(GeologicalSvyLineDbEntitiyDao.class);
        registerDaoClass(GeologicalSvyPlanningLineDbEntityDao.class);
        registerDaoClass(GeologicalSvyPlanningPtDbEntityDao.class);
        registerDaoClass(GeologicalSvyPointDbEntityDao.class);
        registerDaoClass(GeomorphySvyLineDbEntityDao.class);
        registerDaoClass(GeomorphySvyPointDbEntityDao.class);
        registerDaoClass(GeomorphySvyRegionDbEntityDao.class);
        registerDaoClass(GeomorphySvyReProfDbEntityDao.class);
        registerDaoClass(GeomorphySvySamplePointDbEntityDao.class);
        registerDaoClass(GeomorStationDbEntityDao.class);
        registerDaoClass(GeophySvyLineDbEntityDao.class);
        registerDaoClass(GeophySvyPointDbEntityDao.class);
        registerDaoClass(LavaDbEntityDao.class);
        registerDaoClass(LocationEntityDao.class);
        registerDaoClass(RelationTaskDbBeanDao.class);
        registerDaoClass(SamplePointDbEntityDao.class);
        registerDaoClass(StratigraphySvyPointDbEntityDao.class);
        registerDaoClass(TanCaodianDbEntityDao.class);
        registerDaoClass(VolcanicSamplePointDbEntityDao.class);
        registerDaoClass(VolcanicSvyPointDbEntityDao.class);
    }

    public DaoSession newSession() {
        return new DaoSession(db, IdentityScopeType.Session, daoConfigMap);
    }

    public DaoSession newSession(IdentityScopeType type) {
        return new DaoSession(db, type, daoConfigMap);
    }

    /**
     * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} -
     */
    public static abstract class OpenHelper extends DatabaseOpenHelper {
        public OpenHelper(Context context, String name) {
            super(context, name, SCHEMA_VERSION);
        }

        public OpenHelper(Context context, String name, CursorFactory factory) {
            super(context, name, factory, SCHEMA_VERSION);
        }

        @Override
        public void onCreate(Database db) {
            Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION);
            createAllTables(db, false);
        }
    }

    /** WARNING: Drops all table on Upgrade! Use only during development. */
    public static class DevOpenHelper extends OpenHelper {
        public DevOpenHelper(Context context, String name) {
            super(context, name);
        }

        public DevOpenHelper(Context context, String name, CursorFactory factory) {
            super(context, name, factory);
        }

        @Override
        public void onUpgrade(Database db, int oldVersion, int newVersion) {
            Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables");
            dropAllTables(db, true);
            onCreate(db);
        }
    }

}
